// import Mock from 'mockjs'
const Mock = require('mockjs');

var Random = Mock.Random

var temData = {
  status: 200,
  msg: '操作成功！',
  data: {
    totalPage: 4,
    'productList|33': [
      {
        id: '@increment',
        title: "@cword('零一二三四五六七八九十')",
        type: '2',
        status: '1',
        avgResponseTime:Random.float( 0.02, 1 ,0,4),
        'docCount|20-50':22,
        'errorCount':Random.integer(1,99),
        maxResponseTime:Random.float( 0.02, 1 ,0,3),
        resourceType:1,
        serviceName:'@cword(3,5)',
        succCount:Random.integer(1,200),
        'esLayerInfo|0-4':[
          {
            'id|+1':100000,
            remoteAddr:'@ip',
            avgResponseTime:Random.float( 0.02, 1,0,4 ),
            'docCount|20-50':22,
            'errorCount':Random.integer(1,100),
            maxResponseTime:Random.float( 0.02, 1,0,3 ),
            resourceType:1,
            serviceName:'@cword(3,5)',
            succCount:Random.integer(1,200),
            title:'@cword(3,5)',
            type:1
          }
        ]

      },
    ],
  },
}
var tableData = {
  status: 200,
  msg: '操作成功！',
  data: {
    totalPage: 4,
    'productList|31-39': [
      {
        id: '@increment',
        title: "@cword('零一二三四五六七八九十')",
        type: '2',
        status: '1',
        'accessCount|5-30': 6,
        'sumCount|60-100': 60,
        'errorCount|10-30': 10,
        'mapApplicationIp|0-4':[
          {
            'id|+1':1,
            ip:'@ip',
            'count|5-30': 6,
          }
        ]
      },
    ],
  },
}

let url = '/geoplat/log/getIpCountByName'
Mock.mock(
  RegExp(url + ".*"),
  'post',
  (options)=>{
    console.log(url, options,'参数');
    if(options.body){
      for (let [a, b] of options.body.entries()) {
        console.log(a, b, '--------------');
    }
    }
    return Mock.mock(temData);
  }
)
// Mock.mock(
//   url,
//   'post',
//   temData
// )

Mock.mock(
  /\/geoplat\/application\/getApplicationByAccessCount2/,
  'post',
  temData
)

Mock.mock(
  /\/geoplat\/application\/getApplicationByAccessCount1/,
  'post',
  tableData
)

module.exports = {
  Mock
}